package com.mujin.keji.collectionsystem.permissions;

import android.content.Context;
import android.content.pm.PackageManager;

/**
 * 检查权限工具类
 *
 * @author weishixiong
 * @Time 2018-03-27
 */
public class PermissionUtils {
    /**
     * 检查权限
     *
     * @return
     */
    public static boolean hasPermission(Context context, String[] permissions) {
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            PackageManager pm = context.getPackageManager();
            for (String auth : permissions) {
                if (pm.checkPermission(auth, context.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }

    }
}
